/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package rigo.ricard.pris.rs.ac.uns.dmi.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import rigo.ricard.pris.rs.ac.uns.dmi.service.CarPictureLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Rigo Richard
 */
public class CarPictureClp extends BaseModelImpl<CarPicture>
	implements CarPicture {
	public CarPictureClp() {
	}

	public Class<?> getModelClass() {
		return CarPicture.class;
	}

	public String getModelClassName() {
		return CarPicture.class.getName();
	}

	public long getPrimaryKey() {
		return _carPicureId;
	}

	public void setPrimaryKey(long primaryKey) {
		setCarPicureId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_carPicureId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("carPicureId", getCarPicureId());
		attributes.put("adId", getAdId());
		attributes.put("fileName", getFileName());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long carPicureId = (Long)attributes.get("carPicureId");

		if (carPicureId != null) {
			setCarPicureId(carPicureId);
		}

		Long adId = (Long)attributes.get("adId");

		if (adId != null) {
			setAdId(adId);
		}

		String fileName = (String)attributes.get("fileName");

		if (fileName != null) {
			setFileName(fileName);
		}
	}

	public long getCarPicureId() {
		return _carPicureId;
	}

	public void setCarPicureId(long carPicureId) {
		_carPicureId = carPicureId;
	}

	public long getAdId() {
		return _adId;
	}

	public void setAdId(long adId) {
		_adId = adId;
	}

	public String getFileName() {
		return _fileName;
	}

	public void setFileName(String fileName) {
		_fileName = fileName;
	}

	public BaseModel<?> getCarPictureRemoteModel() {
		return _carPictureRemoteModel;
	}

	public void setCarPictureRemoteModel(BaseModel<?> carPictureRemoteModel) {
		_carPictureRemoteModel = carPictureRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			CarPictureLocalServiceUtil.addCarPicture(this);
		}
		else {
			CarPictureLocalServiceUtil.updateCarPicture(this);
		}
	}

	@Override
	public CarPicture toEscapedModel() {
		return (CarPicture)Proxy.newProxyInstance(CarPicture.class.getClassLoader(),
			new Class[] { CarPicture.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		CarPictureClp clone = new CarPictureClp();

		clone.setCarPicureId(getCarPicureId());
		clone.setAdId(getAdId());
		clone.setFileName(getFileName());

		return clone;
	}

	public int compareTo(CarPicture carPicture) {
		long primaryKey = carPicture.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		CarPictureClp carPicture = null;

		try {
			carPicture = (CarPictureClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = carPicture.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{carPicureId=");
		sb.append(getCarPicureId());
		sb.append(", adId=");
		sb.append(getAdId());
		sb.append(", fileName=");
		sb.append(getFileName());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("rigo.ricard.pris.rs.ac.uns.dmi.model.CarPicture");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>carPicureId</column-name><column-value><![CDATA[");
		sb.append(getCarPicureId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>adId</column-name><column-value><![CDATA[");
		sb.append(getAdId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>fileName</column-name><column-value><![CDATA[");
		sb.append(getFileName());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _carPicureId;
	private long _adId;
	private String _fileName;
	private BaseModel<?> _carPictureRemoteModel;
}